<template>
  <div class="dropmenu">
    <van-dropdown-menu>
      <van-dropdown-item :disabled="true" title="全部" />
      <van-dropdown-item
        v-model="value1"
        :options="option1"
        title="价格"
        @change="changepage"
      />
      <van-dropdown-item
        v-model="value2"
        :options="filterCategory"
        title="分类"
        @change="changekind"
      />
    </van-dropdown-menu>

  
  </div>
</template>
<script>
export default {
  name: "",
  props:['filterCategory'],
  data() {
    return {
      value1: 'desc',
    //   value2: "a",
      option1: [
        { text: "价格由高到低", value: 'desc' },
        { text: "价格由低到高", value: 'asc' },
      ],
    //   option2: [
    //     { text: "默认排序", value: "a" },
    //     { text: "好评排序", value: "b" },
    //     { text: "销量排序", value: "c" },
    //   ],
    };
  },
  computed: {
    value2:{
        get(){
            let id=0
            this.filterCategory.forEach(item=>{
            if(item.checked){
                id=item.value
            }
        })
        return id
        },
        set(val){}
    }
  },
  methods: {
    changepage(value){
        // 切换价格排序
        console.log(value);
        // 通过子传父的方式将value传给search
        this.$emit('dropmen',value)
    },
    changekind(value){
        // 切换分类
        console.log(value);
        this.$emit("transfer", value);
    }
  },
  created() {},
  mounted() {},
};
</script>
<style lang='less' scoped>

.dropmenu{
  width: 100%;
  position: sticky;
  top: 54px;
}

</style>
